
import { defineConfig } from 'electron-vite'
import { resolve } from 'path'
import { fileURLToPath } from 'url'

const __dirname = fileURLToPath(new URL('.', import.meta.url))

export default defineConfig({
  main: {
    build: {
      rollupOptions: {
        input: resolve(__dirname, 'electron/main.ts'),
        external: ['electron', 'fs-extra', 'electron-store', 'electron-log', 'chokidar', 'langchain', '@langchain/openai', '@langchain/anthropic', '@langchain/core', 'lodash']
      }
    }
  },
  preload: {
    build: {
      rollupOptions: {
        input: resolve(__dirname, 'electron/preload.ts'),
        external: ['electron']
      }
    }
  },
  renderer: {
    root: './src',
    build: {
      rollupOptions: {
        input: resolve(__dirname, 'src/index.html')
      }
    },
    resolve: {
      alias: {
        '@': resolve(__dirname, 'src'),
        '@components': resolve(__dirname, 'src/components'),
        '@editor': resolve(__dirname, 'src/editor'),
        '@hooks': resolve(__dirname, 'src/hooks'),
        '@styles': resolve(__dirname, 'src/styles'),
        '@utils': resolve(__dirname, 'src/utils'),
          '@plugins': resolve(__dirname, 'src/plugins')
      }
    }
  }
})
